home *** CD-ROM | disk | FTP | other *** search
/ PC Media 23 / PC MEDIA CD23.iso / share / prog / anubis / v320200.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-08-04  |  4.6 KB  |  118 lines

  1. #ifndef  V320200.H
  2. #define  V320200.H
  3.  
  4.  
  5. /****************************************/
  6. /* V320200.H                            */
  7. /* (C) Copyright 1993 David Bollinger   */
  8. /* send comments to CIS ID# 72510,3623  */
  9. /* compiled with Borland C++ 3.0        */
  10. /* pre-calculated tables for stars.c    */
  11. /* (save time & code, waste data space) */
  12. /****************************************/
  13.  
  14. #include <bios.h>
  15. #include <stdlib.h>
  16. #include <time.h>
  17. #include "v320200.h"
  18.  
  19. #define TRUE     (0==0)
  20. #define FALSE    (0==1)
  21. #define AND      &&
  22. #define OR       ||
  23. #define NOT      !
  24. #define MAXX     320       // screen x dimension
  25. #define MAXY     200       // screen y dimension
  26. #define CENTERX  160       // center x coord of screen
  27. #define CENTERY  100       // center y coord of screen
  28.  
  29. /***********************/
  30. /* function prototypes */
  31. /***********************/
  32. void SetVideoMode(int mode);
  33. void PutPixel(int x, int y, int c);
  34. void SetupPalette(void);
  35.  
  36.  
  37. /* screen memory row offsets */
  38. unsigned int ytable[200] =
  39. {0u,320u,640u,960u,1280u,1600u,1920u,2240u,2560u,2880u,3200u,3520u,3840u,
  40.  4160u,4480u,4800u,5120u,5440u,5760u,6080u,6400u,6720u,7040u,7360u,7680u,
  41.  8000u,8320u,8640u,8960u,9280u,9600u,9920u,10240u,10560u,10880u,11200u,11520u,
  42.  11840u,12160u,12480u,12800u,13120u,13440u,13760u,14080u,14400u,14720u,15040u,
  43.  15360u,15680u,16000u,16320u,16640u,16960u,17280u,17600u,17920u,18240u,18560u,
  44.  18880u,19200u,19520u,19840u,20160u,20480u,20800u,21120u,21440u,21760u,22080u,
  45.  22400u,22720u,23040u,23360u,23680u,24000u,24320u,24640u,24960u,25280u,25600u,
  46.  25920u,26240u,26560u,26880u,27200u,27520u,27840u,28160u,28480u,28800u,29120u,
  47.  29440u,29760u,30080u,30400u,30720u,31040u,31360u,31680u,32000u,32320u,32640u,
  48.  32960u,33280u,33600u,33920u,34240u,34560u,34880u,35200u,35520u,35840u,36160u,
  49.  36480u,36800u,37120u,37440u,37760u,38080u,38400u,38720u,39040u,39360u,39680u,
  50.  40000u,40320u,40640u,40960u,41280u,41600u,41920u,42240u,42560u,42880u,43200u,
  51.  43520u,43840u,44160u,44480u,44800u,45120u,45440u,45760u,46080u,46400u,46720u,
  52.  47040u,47360u,47680u,48000u,48320u,48640u,48960u,49280u,49600u,49920u,50240u,
  53.  50560u,50880u,51200u,51520u,51840u,52160u,52480u,52800u,53120u,53440u,53760u,
  54.  54080u,54400u,54720u,55040u,55360u,55680u,56000u,56320u,56640u,56960u,57280u,
  55.  57600u,57920u,58240u,58560u,58880u,59200u,59520u,59840u,60160u,60480u,60800u,
  56.  61120u,61440u,61760u,62080u,62400u,62720u,63040u,63360u,63680u};
  57.  
  58. /* 32 color greyscale palette */
  59. unsigned char palette[32*3] =
  60. {0,0,0,2,2,2,4,4,4,6,6,6,8,8,8,10,10,10,12,12,12,14,14,14,16,16,16,18,18,18,
  61. 20,20,20,22,22,22,24,24,24,26,26,26,28,28,28,30,30,30,32,32,32,34,34,34,
  62. 36,36,36,38,38,38,40,40,40,42,42,42,44,44,44,46,46,46,48,48,48,50,50,50,
  63. 52,52,52,54,54,54,56,56,56,58,58,58,60,60,60,62,62,62};
  64.  
  65. unsigned char norm_palette[32*3] =
  66. {0,0,0     ,255,0,0   ,0,255,0   ,0,0,255   ,255,255,0 ,0,255,255 ,255,0,255  
  67. ,50,50,50  ,90,90,90  ,10,20,30  ,90,50,10  ,100,45,87 ,80,12,200 ,12,100,200 
  68. ,46,47,48  ,49,50,51  ,52,53,54  ,55,56,57  ,58,59,60  ,61,62,63  ,64,65,66 
  69. ,67,68,69  ,70,71,72  ,73,74,75  ,76,77,78  ,79,80,81  ,82,83,84  ,85,86,87 
  70. ,88,89,90  ,91,92,93  ,94,95,96  ,22,23,24};
  71.  
  72.  
  73. /***************************************************************************/
  74. /* BIOS call to set video mode recomended 19 */
  75. /*******************************/
  76. void SetVideoMode(int mode)
  77.     {
  78.     asm   mov   ah, 0
  79.     asm   mov   al, byte ptr mode
  80.     asm   int   10h
  81.     }
  82.  
  83. /***************************************************************************/
  84. /* direct video access to screen to plot a single pixel */
  85. /* destroys ax, bx, es                                  */
  86. /********************************************************/
  87. void PutPixel(int x, int y, int c)
  88.     {
  89.     asm   mov   ax, 0xa000
  90.     asm   mov   es, ax
  91.     asm   mov   bx, word ptr y
  92.     asm   shl   bx, 1
  93.     asm   mov   ax, word ptr ytable[bx]
  94.     asm   add   ax, word ptr x
  95.     asm   mov   bx, ax
  96.     asm   mov   ax, word ptr c
  97.     asm   mov   byte ptr es:[bx], al
  98.     }
  99.  
  100. /***************************************************************************/
  101. /* make a nice greyscale palette */
  102. /* destroys ax, bx, cx, dx, es   */
  103. /*********************************/
  104. void SetupPalette(void)
  105.     {
  106.     asm   mov   ax, SEG norm_palette       // get segment of palette
  107.     asm   mov   es, ax
  108.     asm   mov   dx, OFFSET norm_palette    // get offset of palette
  109.     asm   mov   bx, 0                 // start with color # 0
  110.     asm   mov   cx, 32                // load 32 colors
  111.     asm   mov   ax, 0x1012            // bios function 10 subfunction 12
  112.     asm   int   0x10                  // call bios to load palette
  113.     }
  114.  
  115. /***************************************************************************/
  116.  
  117. #endif
  118.